feat(BREV-2083): Split Byte Sizes into Value and Unit#55
Merged
Conversation
patelspratik
reviewed
Nov 5, 2025
| ImageID string | ||
| InstanceType string | ||
| DiskSize units.Base2Bytes | ||
| DiskSize units.Base2Bytes // TODO: deprecate in favor of DiskSizeByteValue |
Contributor
There was a problem hiding this comment.
the internet says that changing this to
// Deprecated: TODO deprecate in favor of DiskSizeByteValue will actually mark this as deprecated. Though do you actually want to do that, or defer that change?
Contributor
Author
There was a problem hiding this comment.
I am a little worried it will blow up our linter but could give it a shot...
patelspratik
reviewed
Nov 6, 2025
v1/bytes.go
Outdated
Comment on lines
3
to
21
| var zeroBytes = ByteValue{value: 0, unit: Byte} | ||
|
|
||
| type ByteValue struct { | ||
| // Value is the whole non-negative number of bytes of the specified unit | ||
| value uint32 | ||
|
|
||
| // Unit is the unit of the byte value | ||
| unit ByteUnit | ||
| } | ||
|
|
||
| func NewByteValue(value int32, unit ByteUnit) ByteValue { | ||
| if value < 0 { | ||
| return zeroBytes | ||
| } | ||
| return ByteValue{ | ||
| value: uint32(value), | ||
| unit: unit, | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
thoughts on
Suggested change
| var zeroBytes = ByteValue{value: 0, unit: Byte} | |
| type ByteValue struct { | |
| // Value is the whole non-negative number of bytes of the specified unit | |
| value uint32 | |
| // Unit is the unit of the byte value | |
| unit ByteUnit | |
| } | |
| func NewByteValue(value int32, unit ByteUnit) ByteValue { | |
| if value < 0 { | |
| return zeroBytes | |
| } | |
| return ByteValue{ | |
| value: uint32(value), | |
| unit: unit, | |
| } | |
| } | |
| var zeroBytes = byteValue{value: 0, unit: Byte} | |
| type ByteValue interface { | |
| Value() uint32 | |
| Unit() ByteUnit | |
| } | |
| type byteValue struct { | |
| // Value is the whole non-negative number of bytes of the specified unit | |
| value uint32 | |
| // Unit is the unit of the byte value | |
| unit ByteUnit | |
| } | |
| func NewByteValue(value int32, unit ByteUnit) ByteValue { | |
| if value < 0 { | |
| return zeroBytes | |
| } | |
| return byteValue{ | |
| value: uint32(value), | |
| unit: unit, | |
| } | |
| } | |
| func (b byteValue) Value() uint32 { | |
| return b.value | |
| } | |
| func (b byteValue) Unit() ByteUnit { | |
| return b.unit | |
| } | |
so that we don't have to expose the struct and callers must use NewByteValue
patelspratik
previously approved these changes
Nov 6, 2025
patelspratik
approved these changes
Nov 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.